package com.ww.byteBuf;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;

import java.nio.Buffer;
import java.nio.charset.Charset;

/**
 * @ClassName:
 * @author:
 * @Description:
 * @Date
 **/
//bytebuf切片
public class ByteBuf01 {
    public static void main(String[] args) {
        Charset charset = Charset.forName("UTF-8");
        ByteBuf buf = Unpooled.copiedBuffer("Netty in action rocks.", charset);
        //创建一个切片
        ByteBuf copy = buf.slice(0, 15);
        System.out.println(copy.toString(charset));
        buf.setByte(0, (byte) 'J');
        assert buf.getByte(0) == copy.getByte(0);
    }
}
